/*
 * TreeModel.java  0.4.0 / Oct 25, 2010
 *
 * Copyright (c) 2010 - 2011, cute4j.com and contributors.
 *
 * This software is licensed under the LGPL version 2.1 license.
 * A copy of this license is included in the file LICENSE-LGPL.txt.
 */
package com.cute4j.swing.tree;

import com.cute4j.swing.events.TreeModelListener;

/**
 * Tree Model.
 *
 * @author Slobodan Vrkacevic
 * @version 0.4.0
 */
public interface TreeModel {

  /**
   * Returns root.
   *
   * @return root
   */
  public Object getRoot();

  /**
   * Returns child of the specified parent at specified index.
   *
   * @param parent the parent
   * @param index the index
   *
   * @return child of the specified parent at specified index
   */
  public Object getChild(Object parent, int index);

  /**
   * Returns the number of children of specified parent.
   *
   * @param parent the parent
   *
   * @return the number of children of specified parent
   */
  public int getChildCount(Object parent);

  /**
   * Returns <tt>true</tt> if node is leaf.
   *
   * @param node the node
   *
   * @return <tt>true</tt> if node is leaf
   */
  public boolean isLeaf(Object node);

  /**
   * Sets new value for the specified node.
   *
   * @param path the path to the node that should be modified
   * @param value the new value
   */
  public void valueForPathChanged(TreePath path, Object value);

  /**
   * Returns index of child of specified parent.
   *
   * @param parent the parent
   * @param child the child
   *
   * @return index of child of specified parent
   */
  public int getIndexOfChild(Object parent, Object child);

  /**
   * Adds tree mode listener.
   *
   * @param listener the tree mode listener
   */
  public void addTreeModelListener(TreeModelListener listener);

  /**
   * Removes tree mode listener.
   *
   * @param listener the tree mode listener
   */
  public void removeTreeModelListener(TreeModelListener listener);

}
